"""
class Hero():

    def set_name(self, value="剑圣"):
        print("设置英雄名字为:{}".format(value))
        self.name = value

    def print_name(self):
        print("英雄名字是:{}".format(self.name))

    def change_name(self, new_name):
        print("设置{}的新名字为:{}".format(self.name, new_name))
        # 类的内部调用实例方法
        self.set_name(new_name)

# # 类直接调用实例方法的时候,必须传入一个对象
# jiansheng = Hero()
# Hero.set_name(jiansheng)

# # 对象调用实例方法
# # Hero().set_name("gailun")
# gailun = Hero()
# gailun.set_name("盖伦")

# # 对象在类的内部调用实例方法
# xiaopao = Hero()
# xiaopao.set_name("小炮")
# xiaopao.change_name("超级无敌小炮")
"""

"""
class Hero():

    @classmethod
    def pu_tong_gong_ji(cls):
        print("英雄平A了一下!!")

    def func(self):
        # 类的方法可以在类的内部被类和对象调用
        Hero.pu_tong_gong_ji()
        self.pu_tong_gong_ji()

# # 类方法可以直接由类调用
Hero.pu_tong_gong_ji()

# 类方法可以在类的外部被直接调用
jiansheng = Hero()
jiansheng.pu_tong_gong_ji()
jiansheng.func()
"""


"""
class Hero():

    @staticmethod
    def get_time(count=1):
        import time
        for i in range(count):
            print(time.strftime("%Y-%m-%d %H:%M:%S"))
            time.sleep(1)
        return count

# # 静态方法,通过类去找到类中的静态方法,直接调用
# Hero.get_time()
# # 可以由对象直接使用
# jiansheng = Hero()
# jiansheng.get_time(5)
"""

"""
class Hero():

    def __init__(self):
        self.__money = 500

    def __add_money(self):
        print("英雄杀死了一个小兵,赚了35枚金币")
        self.__money+=35

    def kill_xiaobing(self):
        self.__add_money()

# 私有属性,不能在类的外部被直接调用
jiasheng = Hero()
# jiasheng.__add_money()
jiasheng.kill_xiaobing()
"""


class Hero():

    def __init__(self, name, hp=1800, money=500):
        print("使用Hero类初始化一个对象".center(50, "*"))
        self.name = name
        self.hp = hp
        self.__money = money


    def __del__(self):
        print("英雄阵亡了".center(50, "*"))


# jiansheng = Hero("剑圣")
# gailun = Hero("盖伦", 2000)
# print(jiansheng.name)
# del jiansheng
# print(gailun.name)


jiansheng1 = Hero("剑圣")
jiansheng2 = jiansheng1
jiansheng3 = jiansheng2

print(jiansheng1.name)
del jiansheng1
del jiansheng2
del jiansheng3
print(jiansheng2.name)
print(jiansheng3.name)


